Repository navigation
fix(gc): close the lean place-authority gaps left after #783 - #784
Merged
Merged
Conversation
…path Gaps left after #783 (missing evidence stays "no proof", never death): - Worker-route Sandboxes now record place evidence. `sandbox.create` sends the machine name and the generation the home record minted with the create (`Call::Create.place`, frame fields `place_machine`/`generation`); the worker writes them into its own record after the start (`files::save_place`, best effort, never over a record that has a generation), so `mount_place` there returns them and the daemon's bind records the generation token. A worker's root keeps no machine record, so its mounts still carry no incarnation (none is guessed). - Every removal of a Sandbox's home record writes the retirement tombstone first, best effort, reporting a failed write in `left`: `sandbox.remove` on the forgotten, stopped, already-gone and unstarted paths and `forget` (`retire_home`, which writes the home's tombstone for a worker's Sandbox), `lifecycle::reclaim`, and the close's forget paths. A worker's root is not a home: `record::retire` writes nothing there. - One tombstone per name: once a recreated Sandbox's started record is written, the name's older tombstone of the same home goes (`record::drop_retired`); the newer record proves the old generation's mounts dead by itself. A tombstone that is not older is kept. - `machine.remove` keeps deleting `machine/<m>/` with its tombstones; it is refused while a Store or Sandbox uses the machine, and the decision is documented in `record/tombstone.rs`. Tests: new `place_evidence` (worker place, no tombstone in a worker root, recreate drops the older tombstone); `half_created` asserts the unstarted removal's tombstone; `host_frame` round-trips a create with a place. Production LOC: 214,060 -> 214,149 (delta +89) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and compaction parity - An operator release that retains a `done` row now deletes the oldest done rows of the same scope (a mount's Branch) beyond the newest 100 (`DONE_RETAINED`), in the release's transaction (`gc_intent_done_cap.sql`). No schema change: no index, table or column; the scope's rows are found through the existing UNIQUE (scope_kind, scope_id, owner_boot) index, and only `state = 'done'` rows are matched. `gc_intent_release_done` answers the row's scope. - PostgreSQL `release_done` answers what the retain itself answered, so a second (or concurrent) release is `false`/`NotFound` as on SQLite, and only a row this release retained has its session keys released. - PostgreSQL compaction no longer touches a retained done row: its `compaction_intent` read, the status read and both cleanup deletes filter `state <> 'done'`. Tests: `gc_intent_done` gains a cap test (101 rows -> the newest 100 of the Branch; another Branch's row stays). Production LOC: 214,149 -> 214,167 (delta +18) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vers removed
Item 4, a real `safe` verdict:
- New read `HistoryCatalog::gc_liveness(intents)` (persistence:
`admission::liveness`, store-service: `admission::liveness`): the owner
check first, then the place view scoped on the thread, exactly as an
admitting removal judges a conflict. One read transaction, no write.
- `list`/`preview` rows carry `liveness` (`live`, `uncertain`, `dead`) and
`safe` = not `live`, instead of `safe = uncertain` and a prose `reason`.
- `settle` refuses a holder still `live` with `InUse` (fix: the same line
with `--force`) unless `--force`, or `--legacy` for a row without evidence.
- A worker's `store.repair` is sent the calling home's place view and
installs it, as Store calls do.
Item 6, the call surface (2.0 conventions):
- `store.repair_mount_holders(project, branch, action, { op, legacy, force,
operator, limit, cursor })`: a `<store>/<project>` Project argument instead
of a Store name plus a project name; `list`, `preview` and `audit` page by
`limit` (1-1000, default 100) and `cursor` (carrying project, Branch and
action) and answer `{ action, items, next_cursor }`; ops answer
`{ action, op, state }` with state words.
- The repair moved out of `layerfs-store/src/service.rs` into
`layerfs-store/src/repair.rs`: one `Repair` request (frame codec shared by
the local and worker routes) replaces the ten-argument functions and their
`too_many_arguments` allows; `control::store::repair` takes a
`RepairRequest`.
- `project.mount_holders` appears in no doc or source (the doctor check is
`store.mount_holders`), so nothing to drop or build.
Item 7, leftovers with no product caller:
- removed `gc_record_done`/`record_done`/`gc_intent_done_insert.sql`,
`gc_prune_done`/`prune_done`/`gc_intent_done_delete.sql`,
`Param::OptionalI64` and its binders, `admission::audit_value` (replaced by
the per-row `done_value`), and the lease wording plus the unused `now_ms`
argument of `PlaceAuthority::liveness` and `PlaceView`.
Docs: `store.md` section rewritten; GC spec place-writer, audit and repair
bullets; runbook audit line.
Tests deleted (they drove removed APIs): `gc_intent_done`
`preview_retains_a_done_row_without_an_operation` and
`a_prune_deletes_only_the_named_done_rows`. Tests changed: `gc_calls`,
`cli/gc`, `store_repair_worker`, `store_repair_live`, `repair_postgresql`
(new call shape; settle guard and cursor paging asserted), `authority`
(no `now_ms`). New: `gc_place_view` liveness test.
Production LOC: 214,167 -> 214,170 (delta +3)
scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree
reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`repair_postgresql` now creates its project with `project.init` (the call-surface route) instead of `add_project`, so it writes the record shape `store.connect` writes: the address alone plus a saved login. It asserts the 2.0 repair surface on PostgreSQL: rows at most `live` with `safe` false, a settle of a live-looking holder refused `InUse` until forced, and a second release `NotFound` as on SQLite. Run against a private postgres:17 server (trust auth, amcheck). Production LOC: 214,170 -> 214,170 (delta 0) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cord `files::save_place` skipped a worker record that already named a generation. A record an interrupted removal left behind (no daemon, so the create proceeds and `save_sandbox` keeps its fields) could then name an older generation than the home's new record: mounts would record that older value, and the home's view would judge them retired (dead) while live, worse than the base. The caller's machine and generation now replace any other values; on `native` the record is the home's own and already names them, so nothing is written. Tests: `place_evidence` asserts an older leftover generation is replaced. Production LOC: 214,170 -> 214,170 (delta 0) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The persistence page reports `has_more` whenever a page is full, so the repair audit handed out a cursor to an empty page after a full last page. The audit now reads one row at the next page's offset and names the next page only when one follows. Caught by `gc_calls` on Linux. Production LOC: 214,170 -> 214,181 (delta +11) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yifanxuaaa
marked this pull request as ready for review
November 24, 2026 10:09
yifanxuaaa
added a commit
that referenced
this pull request
Nov 24, 2026
…nect-attach Conflicts, resolved keeping both sides: - api store/mod.rs: upstream's new `repair_mount_holders` call is kept; this branch's removal of save_auth, remove_auth and update stands. - layerfs-platform lib.rs and setup/mod.rs: the re-export lists keep both upstream's `provider_state` and this branch's `shares_loopback`. Adapted to this branch's API: control/crates/layerfs-store/tests/repair_postgresql.rs (added upstream) saves the password under the Store's name and records the user in `StoreRecord::connected`, instead of a named saved login. Production LOC: 211342 -> 213839 (delta +2497) Scope and method: first-parent comparison (this branch's 2f81c3d vs the merged tree) with tools/production_loc.py --root on `git archive` of the parent and `git checkout-index -a` of the staged tree. The delta is upstream's work merged in (#781 native boundary, #783, #784 and the other layerfs_v2_0_0 commits since fe9b4d1), not new code on this branch. Reference absent (retired R9c; last counted 65,417 at tree 498dd19). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 24, 2026
yifanxuaaa
added a commit
that referenced
this pull request
Nov 24, 2026
fix(gc): #784 review fixes: tombstones only on confirmed stop, PostgreSQL release once, keyset audit
markankamaransheogarat-sys
pushed a commit
to markankamaransheogarat-sys/layerfs
that referenced
this pull request
Dec 4, 2026
…e start write (Ephemeral-AI-Lab#784 review) A Sandbox's retired tombstone proves its generation's mounts dead once the home record is gone, so it is now written only where the runtime is confirmed stopped, gone or never started: - lifecycle::close no longer writes it for a retired docker record (its container is left for the user) or a record this build does not read (forget_unread: its daemon may still run). - sandbox.remove: the unread-local, foreign, retired-docker and nameless-machine forgets write none (Worker::Ask / Skip); a gone VM or a machine recorded stopped (Worker::Gone) still does. After the close its side ran, only a `Closed` answer or `NoSuchSandbox` writes it; a `Forgotten` answer (with or without `left`) writes none. A forget whose worker refused or was unreachable writes none. - Kept: the normal close, force::close, reclaim and remove_unstarted. - reclaim reports a tombstone it could not write in its answer's `left`; close carries it in the gone refusal's `left` detail and sandbox.remove's NoSuchSandbox arm adds it to `left` (it was dropped). A worker's record now gets its place in the same write that records it started (files::write_started, called by save_sandbox; save_place removed): the caller's place always wins, and a worker record sent no place drops any machine/generation a leftover record kept, so a failure leaves no evidence, never an older generation. lifecycle::start, launch::local::start and save_sandbox take the place with the host and platform. family::create_on runs sandbox.create with a stand-in for the side that starts it on a machine whose calls run in this process; create calls it with dispatch::call. Tests: new tests/retired_tombstone.rs (unread record and retired docker forget through sandbox.remove and lifecycle::close write no tombstone; a forget whose worker keeps its record writes none; gone VM writes one, nameless machine none; a recreate through create_on drops the older tombstone and sends its side the recorded place). half_created.rs: the forced remove's confirmed stop leaves the tombstone; new reclaim test (tombstone written, or its failure in the refusal's `left`). place_evidence.rs: the save_place test is replaced by write_started tests (new place in the start write; a leftover worker record never keeps its older generation; a home record keeps its place). No test deleted. Production LOC: 214259 -> 214288 (delta +29) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markankamaransheogarat-sys
pushed a commit
to markankamaransheogarat-sys/layerfs
that referenced
this pull request
Dec 4, 2026
…ner release (Ephemeral-AI-Lab#784 review) - audit pages by (updated_ms, op_id): `gc_done_intents_branch` takes the last row's place and reads `LIMIT limit+1` for the next cursor (no lookahead read); the cursor place `<updated_ms>:<op>` is validated (malformed is `InvalidInput`) and travels to the worker unchanged as `after`. - a retained done row is stamped max(now, the scope's newest done time + 1) (new `gc_intent_done_newest`, one read through the existing scope index prefix), and the cap never deletes the op it just retained. - PostgreSQL: the owner's release reads its row whatever its state (`gc_intent_get_any`), so after an operator retained it as done the owner still unlocks its own session keys; the done row is neither deleted nor revived. - `gc_mark_uncertain` answers whether a live row was marked; `settle` of a row released since the listing is `NotFound`, and `settle_legacy` counts only marked rows. - `gc_liveness` judges with the supplied view alone (as a removal admits), not the holder's own recorded generation as the current record. No Store format change (two new query files only). Tests added: gc_intent_done a_release_between_audit_pages_neither_skips_nor_repeats_a_row, a_release_stamped_behind_the_newest_row_is_kept_and_listed_last; gc_place_view liveness_with_a_tombstone_only_view_matches_admission; postgresql_gc_fence an_owner_release_after_an_operator_release_unlocks_its_session_keys; store_repair_worker the_worker_judges_with_the_sent_view_and_pages_the_audit_by_key. Changed: a_release_keeps_at_most_the_newest_done_rows_of_its_branch now holds a live and an uncertain intent in the Branch and asserts both survive. None deleted. Production LOC: 214259 -> 214318 (delta +59) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markankamaransheogarat-sys
pushed a commit
to markankamaransheogarat-sys/layerfs
that referenced
this pull request
Dec 4, 2026
… review) - store.md: PostgreSQL rows are never `dead` from place evidence, so most PostgreSQL settles need `--force`; audit pages by (updated_ms, op); the done stamp, the cap keeping the retained row and the PostgreSQL owner release; `settle` of a released row is `NotFound`; `NoSuchStore`, `NoSuchProject` and `NoSuchBranch` in the error table. - GC spec: `store.diagnose` forwards only the typed holder view, not `liveness`/`safe`. - gc_intent_insert.sql: a done row is not revived while retained; once the cap deletes it, its op id can register again. - the call's one-line summary (and the CLI help test) names `settle_legacy`. Production LOC: 214318 -> 214318 (delta 0) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markankamaransheogarat-sys
pushed a commit
to markankamaransheogarat-sys/layerfs
that referenced
this pull request
Dec 4, 2026
…which removals write a tombstone - `calls_table::a_migrated_entry_declares_its_forms_and_the_others_declare_none` failed on layerfs_v2_0_0 since Ephemeral-AI-Lab#784: the call declared `Paging::Cursor` but has no 2.0 answer form, and only entries with a form may declare paging. Declaring a form would reshape its answers (a separate migration), so the entry declares no paging; it still pages by `limit`/`cursor`. - GC spec: a removal writes the retirement tombstone only when the runtime is confirmed stopped, confirmed gone or never started; a forget that sent no signal writes none. Production LOC: 214,347 -> 214,346 (delta -1) scope: tools/production_loc.py (repo-pinned counter), first-parent tree vs committed tree reference absent (retired R9c; last counted 65,417 at tree 498dd19) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markankamaransheogarat-sys
pushed a commit
to markankamaransheogarat-sys/layerfs
that referenced
this pull request
Dec 4, 2026
…bstone (Ephemeral-AI-Lab#784 review) sandbox.remove treated every `NoSuchSandbox` answer from the close its side ran as "confirmed gone" and wrote the Sandbox's retired tombstone. Some of those answers inspect no runtime: `files::reopen` answers "Sandbox <id> has no daemon keys" and `lifecycle::close` answers "no Sandbox <id> runs on this machine" without looking at the daemon. A tombstone there could prove a still-running daemon's mounts dead. Now only a `NoSuchSandbox` whose detail says `containerGone` (its side found the daemon gone or stopped and reclaimed it) writes the home tombstone; any other is removed with no tombstone, which is only "no proof". The spec's Place writers paragraph says so. Test: retired_tombstone a_sandbox_without_daemon_keys_is_removed_without_a_tombstone (macOS: a native record this build reads, no daemon keys); it fails with the old arm. The recreate test's Store setup moved to a shared helper. Production LOC: 214,346 -> 214,349 (delta +3) core 42,486 -> 42,486 (0) engine 98,258 -> 98,258 (0) control 63,227 -> 63,230 (+3) layerfs-sandbox +3 api 10,375 -> 10,375 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent a1503aa and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markankamaransheogarat-sys
pushed a commit
to markankamaransheogarat-sys/layerfs
that referenced
this pull request
Dec 4, 2026
…once (Ephemeral-AI-Lab#784 review) PostgreSQL session advisory keys are reference-counted, one level per op a session registered. `release` read the keys from the row whatever its state, so an op released twice in the same session (an operator `release_done` in the owner's own session, then the owner's release; or a repeated release) unlocked twice and dropped the level a second live mount of that session held on the same Branch. The Session now records the ops it registered (`held_ops`): `register` records the op once its keys are taken, and `release` and `release_done` unlock only when `take_op` finds the op still held, so each registered op unlocks exactly once and an op another session registered unlocks nothing. SQLite is unchanged. Test: postgresql_gc_fence a_repeated_release_unlocks_its_op_once (two mounts in one session on one Branch; operator release, owner release and a repeat of the first; the Branch key stays held until the second is released); it fails with the old unlock. Production LOC: 214,349 -> 214,367 (delta +18) core 42,486 -> 42,486 (0) engine 98,258 -> 98,276 (+18) layerfs-persistence +18 control 63,230 -> 63,230 (0) api 10,375 -> 10,375 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 9f58434 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the remaining gaps in the lean GC place authority after #783. The rule throughout: nothing is worse than the base; missing evidence is never death.
Stacked on #783 (base
claude/p4-lean-int). Once #783 merges intolayerfs_v2_0_0, this PR is rebased onto it and retargeted.Items
sandbox.createsends the home-minted machine name and generation (Call::Create.place). The worker writes them into its own record (files::save_place; the caller's values always win over a leftover record), so worker mounts record the generation token. A worker root has no machine record, so no incarnation is recorded or guessed.sandbox.removewrites it best-effort before the home record goes, on the stopped, forgotten, already-gone and unstarted paths and inforget; this covers worker Sandboxes too. So dolifecycle::reclaimand the close's forget paths. A failed write is reported inleft. A worker root is no home and gets no tombstone.machine.removestill deletesmachine/<m>/and its tombstones: it is refused while the machine is in use, and this is documented.drop_retired). An operator release keeps at most the newest 100donerows per Branch, throughgc_intent_done_cap.sql. There is no schema change: the existingUNIQUE (scope_kind, scope_id, owner_boot)index finds the rows.HistoryCatalog::gc_liveness: the owner check, then the scoped place view, as admission judges.list/previewrows carryliveness(live/uncertain/dead) andsafe(notlive).settlerefuses aliveholder withInUseunless--force(or--legacy). A worker's repair is sent the home's place view.release_doneanswers the retain's own result, so a second release isNotFound. PG compaction reads and deletes filterstate <> 'done'.repair_postgresqlnow sets up throughproject.init.store.repair_mount_holders(project, branch, action, { op, legacy, force, operator, limit, cursor })takes a<store>/<project>argument and pages bylimit/cursor→{ action, items, next_cursor }. Ops answer state words ({ action, op, state }), and the prosereasonis gone. The logic moved tolayerfs-store/src/repair.rswith oneRepairrequest shared by the local and worker routes.project.mount_holdersis not mentioned in any doc or source, so nothing to build or drop.gc_record_done/record_done/gc_intent_done_insert.sql,gc_prune_done/prune_done/gc_intent_done_delete.sql,Param::OptionalI64,audit_value, and the lease wording plus the unusednow_msinPlaceAuthority::liveness.Deleted tests (they drove removed APIs):
gc_intent_done::preview_retains_a_done_row_without_an_operation,gc_intent_done::a_prune_deletes_only_the_named_done_rows.Verification
cargo +1.85.1 clippy --workspace --all-targets -- -D warnings: clean on macOS. Linux clippy did not run: the pinned Linux build image has no clippy component. Linux code was compile-checked by the Linux test build.place_evidence,host_frame,record_codec,half_created; historyauthority; persistencegc_intent_done,gc_place_view,gc_place_writers,admission,sqlite_compact_done,visibility_guard,semantic_admission,writer_admission,gc_backfill; store-serviceadmission,place_incarnation; cligc. All pass.postgresql_gc_fence,_gc_mark,_gc_mark_edges,_status,_acquisition_compaction,_compact,_diagnostic, and storerepair_postgresql. All pass.tools/worktree.pyin Docker: apigc_calls, controlstore_repair_worker,store_repair_live,mount_place_authority, sandboxplace_evidence,half_created. All pass (gc_callscaught the audit-cursor bug fixed in 1b17dbb).main, so it did not run here.Production LOC: 214,060 -> 214,181 (delta +121) across six commits; each commit records its own line.
🤖 Generated with Claude Code